const $ = (id) => {
    return document.getElementById(id)
}

const convert = (time) => {
    const min = ('0' + Math.floor(time / 60)).substr(-2)
    const seconds = ('0' + Math.floor(time % 60)).substr(-2)
    return min + ':' + seconds
}

// 追加类名
const addClass = (dom, name) => {
    const className = dom.className
    const classList = dom.classList
    dom.className = classList.contains(name) ? className : (className + ' ' + name)
    return dom
}

// 删除类名
const removeClass = (dom, name) => {
    if (dom) {
        let className = dom.className
        dom.className = className.replace(name, '').trim()
    }
    return dom
}

module.exports.$ = $
module.exports.convert = convert
module.exports.addClass = addClass
module.exports.removeClass = removeClass